home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource5 / 310_01 / char.st < prev    next >
Text File  |  1990-04-20  |  1KB  |  69 lines

  1. Class Char :Magnitude
  2. [
  3.     == aChar
  4.         ^ <SameTypeOfObject self aChar>
  5.             ifTrue:  [<CharacterEquality self aChar>]
  6.             ifFalse: [false]
  7. |    < aChar
  8.         ^ <SameTypeOfObject self aChar>
  9.             ifTrue:  [<CharacterLessThan self aChar>]
  10.             ifFalse: [self compareError]
  11. |
  12.     = aChar
  13.         ^ <SameTypeOfObject self aChar>
  14.             ifTrue:  [<CharacterEquality self aChar>]
  15.             ifFalse: [self compareError]
  16. |    > aChar
  17.         ^ <SameTypeOfObject self aChar>
  18.             ifTrue:  [<CharacterGreaterThan self aChar>]
  19.             ifFalse: [self compareError]
  20. |
  21.     asciiValue
  22.         ^ <CharacterToInteger self>
  23. |
  24.     asLowercase
  25.         ^ <IsUpper self>
  26.             ifTrue:  [<ChangeCase self>]
  27.             ifFalse: [self]
  28. |
  29.     asUppercase
  30.         ^ <IsLower self>
  31.             ifTrue:  [<ChangeCase self>]
  32.             ifFalse: [self]
  33. |
  34.     asString
  35.         ^ <CharacterToString self>
  36. |
  37.     compareError
  38.         ^ self error: 'char cannot be compared to non char'
  39. |
  40.     digitValue        | i |
  41.         ((i <- <DigitValue self>) isNil)
  42.             ifTrue: [self error: 'digitValue on nondigit char'].
  43.         ^ i
  44. |
  45.     isAlphaNumeric
  46.         ^ <IsAlnum self>
  47. |
  48.     isDigit
  49.         ^ self between: $0 and: $9
  50. |
  51.     isLetter
  52.         ^ self isLowercase or: [self isUppercase]
  53. |
  54.     isLowercase
  55.         ^ self between: $a and: $z 
  56. |
  57.     isSeparator
  58.         ^ <IsSpace self>
  59. |
  60.     isUppercase
  61.         ^ (self between: $A and: $Z)
  62. |
  63.     isVowel
  64.         ^ <IsVowel self>
  65. |
  66.     printString
  67.         ^ '$' , <CharacterToString self>
  68. ]
  69.